package littlewhisker.components {

	import littlewhisker.globals.constants.errortypes.UIErrorTypes;
	import littlewhisker.managers.ErrorManager;
	import flash.events.IEventDispatcher;
	import flash.display.Sprite;
	import flash.events.EventDispatcher;
	/**
	 * @author Philip
	 */
	public class AbstractComponent extends EventDispatcher implements IComponent {
		
		private var _eventDispatcher:IEventDispatcher;
	
		private var _asset:Sprite;
		
		public function get eventDispatcher() : IEventDispatcher {
			return _eventDispatcher;
		}
		
		public function set eventDispatcher(eventDispatcher : IEventDispatcher) : void {
			_eventDispatcher = eventDispatcher;
		}
		
		public function get asset() : Sprite {
			return _asset;
		}
		
		public function set asset(asset : Sprite) : void {
			if(_asset){
				 ErrorManager.throwError(UIErrorTypes.ASSIGN_MULTIPLE_ASSETS) 
			} else {
				 _asset = asset;
				 if(!eventDispatcher) eventDispatcher = asset; 
			}
		}
	}
}
